extends ./layout

block contentAll
  .main

    .user
      .login-logo 
        h2 SKY-BlOG
      //- span
      //-   i.fa.fa-user-circle-o.fa-3x.login-fa
      .login
        .inset
          // ---start-main--
          form(action='', method='post', onsubmit="return false;")
            div.form-item
              span
                label(for='username' ) 用户名
              span
                input#username.textbox(type='text',required='true',name='username')
            div.form-item
              span
                label(for='#password') 密 &nbsp;&nbsp;&nbsp;码
              span
                input#password.password(type='password',required='true',name="password")
              script(type="text/javascript").
                function submitLogin(){
                  var username = $("#username").val();
                  var password = $("#password").val();
                  $.ajax({
                    url:'/user/login',
                    data:{
                      username:username,
                      password:password
                    },
                    type:'POST',
                    success:function(msg){
                      if(!msg.status){
                        Swal({
                          title: msg.text,
                          type: 'error',
                          confirmButtonText: "OK",
                        }).then(function(isConfirm){
                          if(isConfirm === true){
                            return 0;
                          }
                        });
                      }else{
                        Swal({
                          title: msg.text,
                          type: 'success',
                          confirmButtonText: "OK",
                        }).then(function(isConfirm){
                          if(isConfirm.value == true){
                            window.location.href='/';
                          }
                        });
                      }
                    }
                  });
                }    
            .sign
              .submit
                input(type='submit', onclick='return submitLogin()', value='马上登录')
              span.forget-pass
                a(href='#') 忘记密码?
              .clear  


